package com.gobi.ribbon.consumer.controller;

/**
 * Created by YingYou on 2019/12/27.
 */

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class GainRestTemplate implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    private RestTemplate jibaRestTemplate;

    public GainRestTemplate() {
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }


    @Autowired
    @MyLoadBalanced
    public void setJibaRestTemplate(RestTemplate jibaRestTemplate) {
        this.jibaRestTemplate = jibaRestTemplate;
    }

    @Autowired
    @LoadBalanced
    public void setRestTemplate(RestTemplate jibaRestTemplate2) {
        this.jibaRestTemplate = jibaRestTemplate2;
    }

    public void look() {
        String[] beanNamesForType = applicationContext.getBeanNamesForType(RestTemplate.class);
    }
}
